package com.example.jetpacktest.viewmodel

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import com.example.jetpacktest.R
import kotlinx.android.synthetic.main.activity_view_model_example.*

class ViewModelExampleActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_view_model_example)
        var viewModel = ViewModelProvider(this).get(TimerViewModel::class.java)
        viewModel.setTheCountChangeListener(object : TimerViewModel.CountChangeListener {
            override fun onCountChanged(count: Int) {
                runOnUiThread { showCount?.text = count.toString() }
            }
        })
        viewModel.startCount()
    }
}
